<template>
  <div>child组件</div>
  <p>{{ msg }}</p>
  <button @click="childBtn"> 子组件按钮</button>
</template>

<script>
import {reactive, toRefs, defineComponent,} from "vue";

export default defineComponent({
  name: 'child',
  props: ['msg'],
  beforeCreate() {
    console.log('beforeCreate')
  },
  mounted() {
    console.log('mounted')
    console.log('this', this)
  },
  setup(props, context) {
    console.log('setup-child')
    console.log('组件传递的数据', props.msg)
    // console.log(context.emit)
    const childBtn = () => {
      // context.emit('changeV', 'hhahah')
      console.log(context.attrs.msg2) //props未接收的参数
    }
    return {
      childBtn
    }
  }

})
</script>

<style lang="scss" scoped>
</style>